package com.dream.vo.master;

import java.io.Serializable;

import javax.validation.constraints.Pattern;

import org.hibernate.validator.constraints.NotBlank;

import com.dream.model.master.ProductPart;
import com.dream.utils.check.PatternExpConstants;
import com.dream.vo.base.FirstGroup;
import com.dream.vo.base.QueryVO;

public class ProductPartVO extends QueryVO implements Serializable {

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 5606240438385683405L;
	
	@NotBlank(message = "err0001",groups = {FirstGroup.class})
	private String id;

	@NotBlank(message = "err0001",groups = {FirstGroup.class})
	private String name;
	
	private Long makeType;
	
	private Long level;
	
	@Pattern(regexp = PatternExpConstants.FLOAT_PAT, message = "err0034",groups = {FirstGroup.class})
	private String costPrice;
	
	@Pattern(regexp = PatternExpConstants.FLOAT_PAT, message = "err0034",groups = {FirstGroup.class})
	private String centerPrice;
	
	@Pattern(regexp = PatternExpConstants.FLOAT_PAT, message = "err0034",groups = {FirstGroup.class})
	private String netPrice;
	
	@Pattern(regexp = PatternExpConstants.FLOAT_PAT, message = "err0034",groups = {FirstGroup.class})
	private String customerPrice;
	
	private Boolean isBack;
	
	private Boolean isOver;
	
	private Boolean isBuy;
	
	private Boolean isRelative;
	
	@Pattern(regexp = PatternExpConstants.NUM_PAT, message = "err0020",groups = {FirstGroup.class})
	private String repairMonth;
	
	private String comments;
	
	private String  keyword;
	
	public String getKeyword() {
		return keyword;
	}

	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	
	public Long getMakeType() {
		if(makeType.compareTo(0L)<=0){
			return null;
		}
		return makeType;
	}

	public void setMakeType(Long makeType) {
		this.makeType = makeType;
	}

	public Long getLevel() {
		if(level.compareTo(0L)<=0){
			return null;
		}
		return level;
	}

	public void setLevel(Long level) {
		this.level = level;
	}

	public String getCostPrice() {
		return costPrice;
	}

	public void setCostPrice(String costPrice) {
		this.costPrice = costPrice;
	}

	public String getCenterPrice() {
		return centerPrice;
	}

	public void setCenterPrice(String centerPrice) {
		this.centerPrice = centerPrice;
	}

	public String getNetPrice() {
		return netPrice;
	}

	public void setNetPrice(String netPrice) {
		this.netPrice = netPrice;
	}

	public String getCustomerPrice() {
		return customerPrice;
	}

	public void setCustomerPrice(String customerPrice) {
		this.customerPrice = customerPrice;
	}

	
	public Boolean getIsBack() {
		return isBack;
	}

	public void setIsBack(Boolean isBack) {
		this.isBack = isBack;
	}

	public Boolean getIsOver() {
		return isOver;
	}

	public void setIsOver(Boolean isOver) {
		this.isOver = isOver;
	}

	public Boolean getIsBuy() {
		return isBuy;
	}

	public void setIsBuy(Boolean isBuy) {
		this.isBuy = isBuy;
	}

	public Boolean getIsRelative() {
		return isRelative;
	}

	public void setIsRelative(Boolean isRelative) {
		this.isRelative = isRelative;
	}

	public void setRelative(boolean isRelative) {
		this.isRelative = isRelative;
	}

	public String getRepairMonth() {
		return repairMonth;
	}

	public void setRepairMonth(String repairMonth) {
		this.repairMonth = repairMonth;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	public void populate(ProductPart part){
		
		if(part == null){return;}
		
		part.setId(id);
		part.setName(name);
		part.setMakeType(makeType);
		part.setLevel(level);
		
		part.setIsBack(isBack);
		part.setIsBuy(isBuy);
		part.setIsOver(isOver);
		part.setIsRelative(isRelative);
		
		part.setRepairMonth(Integer.parseInt(repairMonth));
		part.setComments(comments);
		part.setKeyword(keyword);
		
		part.setCostPrice(Float.parseFloat(costPrice));
		part.setCenterPrice(Float.parseFloat(centerPrice));
		part.setNetPrice(Float.parseFloat(netPrice));
		part.setCustomerPrice(Float.parseFloat(customerPrice));
		
	}
	
}
